package com.qg.wcsopcuaqj.dispatch.configuration;

import com.qg.wcsopcuaqj.business.service.ITWcsRgvAlarmService;
import com.qg.wcsopcuaqj.opcua.selfunion.UAService;
import com.qg.wcsopcuaqj.taskPool.RGVHeartRunnable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import static com.qg.wcsopcuaqj.taskPool.QGSThreadPool.AGVHeart;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2022/7/5 20:12
 */
@Component
@Order(value = 1)
public class InitialHeartBeat implements ApplicationRunner {
    @Autowired
    private UAService uaService;

    @Autowired
    private ITWcsRgvAlarmService alarmService;

    private static Boolean connectStatus;

    public static synchronized Boolean getConnectStatus(){
        return connectStatus;
    }
    public static synchronized void setConnectStatus(Boolean b){
        connectStatus = b;
    }

    public InitialHeartBeat(){
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.err.println("=======begin heart beat to plc=======");
        //run心跳
        RGVHeartRunnable runnable = new RGVHeartRunnable(uaService,alarmService);
        AGVHeart.submit(runnable);

    }
}
